<style scoped>
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .rj-cell.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell label {
    color: #333;
    font-size: 14px;
    width: 44%;
    display: inline-block;
    padding: 5px 3%;
    text-align: right;
  }
  .rj-cell span {
    font-size: 14px;
    color: #333;
    display: inline-block;
    width: 50%;
  }
  .rj-cell.note label{
    float: left;
  }
  .rj-cell.note span{
    width: 80%;
    display: inline-block;
  }
  .weui-cell {
    background: #fff;
  }
  #acts span {
    font-size: 14px;
  }
  .halfbtn {
    display: inline-block;
    width: 49%;
  }
  .weui-label{
    /*width: 130px;*/
    text-align: left;
  }

  .weui-select {
    height: auto;
    line-height: normal;
  }
  *{
    list-style:none;
  }
  /*body{*/

  /*}*/
  .weui-cell_select {
    padding: 10px 15px;
  }
  .weui-cells__title {
    text-align: left;
  }
  .hide {
    display: none;
  }
  #acts {
    font-size: 0;
  }
  #acts span {
    font-size: 14px;
  }
  input.time {
    border: none;
    font-size: 16px;
    padding-left: 10px;
  }

  .weui-cells__title {
    background: #eee;
    padding: 5px 10px;
    margin-bottom: 0;
  }
  .weui-cell.temp {
    padding: 10px 15px;
    background: #f5f5ef;
  }
  .oitem {
    margin: 5px;
  }
</style>
<template>
  <div class="oitem">
    <div class="weui-cells__title">货品明细{{no + 1}}
      <p id="acts" style="float: right;color: #1aad19;">
        <span style="padding-left: 5px;" @click="delItem">删除</span>
      </p>
    </div>
    <input type="hidden" :name="'items[' + no + '].guid'" :value="itemNo.guid" />
    <div class="weui-cell temp fir">
      <div class="weui-cell__hd"><label class="weui-label">产品</label></div>
      <div class="weui-cell__bd">
        <select class="weui-select product">
          <option :value="itemNo.productid" selected>{{itemNo.product }}</option>
        </select>
      </div>
    </div>
    <div class="weui-cell temp" v-if="type == 1">
      <div class="weui-cell__hd"><label class="weui-label">规格 </label></div>
      <div class="weui-cell__bd">
        <select class="weui-select spec">
          <option :value="itemNo.specguid" selected>{{itemNo.spename }}</option>
        </select>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ApplySrItem2',
  data () {
    return {
      value: '',
      defaultResult: [],
      currentProduct: '',
      specifications: []
    }
  },
  props: [
    'itemNo',
    'isLast',
    'products',
    'type',
    'no'
  ],
  computed: {
  },
  watch: {
    'currentProduct': function(){
      this.getSpecByPro();
    }
  },
  methods: {
    addItem: function() {
      this.$emit('doAddItem');
    },
    delItem: function() {
      this.$emit('doDelItem');
    },
    product(index) {
      return 'product' + index;
    },
    onSearch (val) {
      this.$emit('doSearch',val)
    },
    onCancel () {
      this.$emit('doSearch', '')
    },
    onSelect (val) {
      this.value = val;
    },
    getSpecByPro: function() {
      this.axios({
        method: 'get',
        url: '/produce/Whinapply!getSpeByproduct.action',
        params: {productid: this.currentProduct, stats: '1,4'}
      }).then((response) => {
        if (response.data.msg == 'success') {
          let data = response.data;
          this.specifications = data.specifications;
        } else {
          this.toastError("系统错误");
        }

      })
    },
  }
}
</script>
